



/**
 * 
 * 在字符串中查找字符 abcdef
 * 
 * 
 * @param {*} source 
 * @returns 
 */
function findStr5(source) {
    let findIndex = -1;

    if(source != null && source.length > 5) {
        for(let index in source) {
            let c1 = source.charAt(index);
            let c2Index = parseInt(index) + 1;
            let c3Index = c2Index + 1;
            let c4Index = c3Index + 1;
            let c5Index = c4Index + 1;
            let c6Index = c5Index + 1;
            // console.log("index:" + index + " c6Index:" + c6Index);
            if(c6Index <= source.length) {
                let c2 = source.charAt(c2Index);
                let c3 = source.charAt(c3Index);
                let c4 = source.charAt(c4Index);
                let c5 = source.charAt(c5Index);
                let c6 = source.charAt(c6Index);
                if(c1 == "a" && c2 == "b" && c3 == "c" && c4 == "d" && c5 == "e" && c6 == "f") {
                    findIndex = index;
                    break;
                }
            }
        }

    }


    return findIndex;
}

let result1 = findStr5("abcdefghyisd");
console.log(" result1:" + result1);

let result2 = findStr5("demo2021abcdefasd");
console.log(" result2:" + result2);

let result3 = findStr5("demoabcdef");
console.log(" result3:" + result3);

let result4 = findStr5("demoabcde");
console.log(" result4:" + result4);